import request from '@/utils/request'

enum Api{
  //获取所有skuList数据
  getAllSkuListApi =  '/admin/product/list',
  //添加skuInfo
  saveSkuInfoApi = '/admin/product/saveSkuInfo',
  //查看skuList数据
  checkSkuListApi = '/admin/product/findBySpuId',
  //skuInfo上架
  skuOnSaleApi = '/admin/product/onSale',
  //skuInfo下架
  skuCancelApi =  '/admin/product/cancelSale',
  //删除skuInfo
  deleteSkuInfoApi = '/admin/product/deleteSku',
  // 查看skuInfo数据
   getSkuInfoApi = '/admin/product/getSkuById'
}



 //添加skuInfo
export const reqSaveSkuInfo = (skuInfo)=>{
  return request.post<any,any>(Api.saveSkuInfoApi,skuInfo)
}

//获取所有的skuList数据
export const reqGetAllSkuListData = (page:number, limit:number)=>{
  return request.get<any,any>(Api.getAllSkuListApi+`/${page}/${limit}`)
}

//根据spuId 查看skuList
export const reqCheckSkuListData = (spuId)=>{
  return request.get(Api.checkSkuListApi +`/${spuId}`)
}

//上架
export const reqSkuOnSale = (skuId) =>{
  return request.get(Api.skuOnSaleApi +`/${skuId}`)
}

//下架
export const reqSkuCancelSale = (skuId)=>{
  return request({
    url: Api.skuCancelApi +`/${skuId}`,
    method: 'get'
  })
}

//删除skuInfo这条数据
export const reqDeleteSkuInfo = (skuId) => {
  return request.delete(Api.deleteSkuInfoApi + `/${skuId}`)
}

//根据skuId获取某一个skuInfo数据
export const reqGetSkuInfoData = (skuId) => {
  return request.get(Api.getSkuInfoApi + `/${skuId}`)
}
